package io.sdl.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.ChannelInterceptor;


@Configuration
public class StompLoggingConfig {

    @Bean
    public ChannelInterceptor stompFrameLogger() {
        return new ChannelInterceptor() {
            @Override
            public Message<?> preSend(Message<?> message, MessageChannel channel) {
                System.out.println(">>> STOMP Frame: " + message.getHeaders().get("stompCommand"));
                return message;
            }
        };
    }
}
